@extends('admin/index')
@section('name')
    <h1><span class="label label-default"> 权限列表  </span></h1>
    <hr>

    <table class="table table-bordered  table-hover" id="tent">
        <tr>
            <th>ID</th>
            <th>权限名</th>
            <th>控制器</th>
            <th>方法</th>
            <th>操作</th>
        </tr>
        @foreach($result as $v)
            <tr>
                <td>{{$v->id}}</td>
                <td>{{$v->per_name}}</td>
                <td>{{$v->per_contor}}</td>
                <td>{{$v->per_func}}</td>
                <td>
                    <a href="/per/update/{{$v->id}}" class="btn btn-info">修改</a>
                    <button class="btn btn-danger" id="but1" onclick="del({{$v->id}})">删除</button>
                </td>
            </tr>
        @endforeach
    </table>
    {{$result->links()}}

    <script>
        function del($id) {
            //接收id
            var id = $id;
            $.ajax({
                type: 'get',
                url: "{{url('/per/del')}}/" + id,
                data: id, //请求数据
                success: function (data) {
                    if (data == 1) {
                        $("table#tent tr").click(function () {
                            $(this).remove();
                        });
                        window.location.href='{{url('/permiss')}}';
                    }
                },
                error: function () {
                    alert('ajax请求失败');
                }
            });
        }
    </script>
@endsection
